import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import get_user from '@feidao/web/atom/browser/storage/get';
import { file_url, spaceid } from './config';
////////////////////////////////////////////////////////////////////////////////
// import atoms
////////////////////////////////////////////////////////////////////////////////

export default async function a001(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	const user = await get_user('user');

	// const data = await nodejs<{ companyname: string }>(send_msg, 'top_m_find', { systemid, staff_no: user.usercode }, false, false);
	fd.data.node.querySelector('[data-feidao-name="retailer_store_name"]').innerHTML = '公司名称';
	if (user && user.avatar_path) {
		fd.data.node.querySelector<HTMLImageElement>('[data-feidao-name="msg"]').src = `${file_url}getfile?productid=${spaceid}&id=${user.avatar_path}`;
		fd.data.node.querySelector('[data-feidao-id="name"]').innerHTML = user.user_name;
		fd.data.node.querySelector('[data-feidao-id="name_1"]').innerHTML = user.user_name;
	}
	else {
		fd.data.node.querySelector<HTMLImageElement>('[data-feidao-name="msg"]').src = "./images/1.png";
	}
	setInterval((() => {

		const nowtime = new Date();
		const year = nowtime.getFullYear();
		const month = nowtime.getMonth() + 1;
		const date = nowtime.getDate();
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-time]').innerText = year + "年" + month + "月" + date + "日" + " " + nowtime.toLocaleTimeString('chinese', { hour12: false });
	}), 1000);

}

